package sol.leetcode;

/**
 * Container With Most Water
 */
public class Issue011 {
    public int maxArea(int[] height) {
        int i = 0, j = height.length - 1;
        int maxArea = 0;
        while (i < j) {
            maxArea = Math.max(maxArea, (j - i) * Math.min(height[i], height[j]));
            if (height[i] < height[j])
                i++;
            else
                j--;
        }
        return maxArea;
    }

    public static void main(String[] args) {
        int[] height = {2, 3, 5, 1, 2, 3};
        System.out.println(new Issue011().maxArea(height));
    }
}
